package com.dianping.cat.consumer.heartbeat.model.transform;
import com.dianping.cat.consumer.heartbeat.model.entity.Detail;
import com.dianping.cat.consumer.heartbeat.model.entity.Disk;
import com.dianping.cat.consumer.heartbeat.model.entity.Extension;
import com.dianping.cat.consumer.heartbeat.model.entity.HeartbeatReport;
import com.dianping.cat.consumer.heartbeat.model.entity.Machine;
import com.dianping.cat.consumer.heartbeat.model.entity.Period;
import java.util.ArrayList;
import java.util.List;

public class DefaultLinker implements ILinker {
  private boolean m_deferrable;

  public DefaultLinker(boolean deferrable) {
/* 15 */     this.m_deferedJobs = new ArrayList();


/* 18 */     this.m_deferrable = deferrable;
  }
  private List<Runnable> m_deferedJobs;
  public void finish() {
/* 22 */     for (Runnable job : this.m_deferedJobs) {
/* 23 */       job.run();
    }
  }


  public boolean onDetail(final Extension parent, final Detail detail) {
/* 29 */     if (this.m_deferrable) {
/* 30 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 33 */               parent.addDetail(detail);
            }
          });
    } else {
/* 37 */       parent.addDetail(detail);
    }

/* 40 */     return true;
  }


  public boolean onDisk(Period parent, Disk disk) {
/* 45 */     parent.addDisk(disk);
/* 46 */     return true;
  }


  public boolean onExtension(final Period parent, final Extension extension) {
/* 51 */     if (this.m_deferrable) {
/* 52 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 55 */               parent.addExtension(extension);
            }
          });
    } else {
/* 59 */       parent.addExtension(extension);
    }

/* 62 */     return true;
  }


  public boolean onMachine(final HeartbeatReport parent, final Machine machine) {
/* 67 */     if (this.m_deferrable) {
/* 68 */       this.m_deferedJobs.add(new Runnable()
          {
            public void run() {
/* 71 */               parent.addMachine(machine);
            }
          });
    } else {
/* 75 */       parent.addMachine(machine);
    }

/* 78 */     return true;
  }


  public boolean onPeriod(Machine parent, Period period) {
/* 83 */     parent.addPeriod(period);
/* 84 */     return true;
  }
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/lib/cat-consumer-3.0.0.jar!/com/dianping/cat/consumer/heartbeat/model/transform/DefaultLinker.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */